{include file="public/_meta" /}
<body>
<div class="wrapper">

    {include file="public/_header" /}

    <!-- Sidebar -->
    {include file="public/_menu" /}
    <!-- End Sidebar -->

    <div class="main-panel">

        <div class="content">
            <div class="page-inner">

                <!-- 面包屑 -->
                {include file="public/_page_header" /}

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="d-flex align-items-center">
                                    <h4 class="card-title">城市情况备注</h4>

                                </div>
                                <form class="row">




                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="cityname" value="{$cityname}" placeholder="请输入城市">
                                        </div>
                                    </div>


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-primary">查询</button>
                                            <a href="{:url('Operate/cityRemark')}" class="btn btn-info" style="color: white;position: absolute;left: 110px;">重置</a>
                                        </div>
                                    </div>

                                </form>

                            </div>


                            <div class="card-body">
                                <!-- Modal2 -->
                                <div class="modal fade" id="addRowModal2" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold">编辑</span>

                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal2">
                                                    <div class="row">


                                                            {volist name="products" id="vo"}
                                                        <div class="form-group form-inline col-md-12">
                                                            <label for={$vo} class="col-md-3 col-form-label"><font style="vertical-align: inherit;">{$vo}指导价</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" name="pro_price[{$key}]" id="pro_price_{$key}" placeholder="{$vo}指导价">
                                                            </div>
                                                        </div>

                                                            {/volist}

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="remark" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">备注</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <textarea id="remark" name="remark" class="form-control input-full" style="height: 300px!important"></textarea>
                                                            </div>
                                                        </div>


                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <input type="hidden" name="id" id="id2" value="">
                                                        <button type="submit" id="addRowButton2" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                                <div class="table-responsive">
                                    <table id="add-row" class="display table table-striped table-hover" >
                                        <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>城市编码</th>
                                            <th>城市</th>
                                            <th>指导价</th>
                                            <th>备注</th>
                                            <th>修改时间</th>

                                            <th style="width: 10%">操作</th>
                                        </tr>
                                        </thead>

                                        <tbody>

                                        {volist name="infos" id="vo"}
                                        <tr>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.code}</td>
                                            <td>{$vo.province}-{$vo.name}</td>
                                            <td>
                                                {volist name="vo['pro_price']" id="voo"}
                                                {$voo.name}：{$voo.pro_price} 元<br>
                                                {/volist}

                                            </td>
                                            <td style="white-space: pre-wrap;align-items: center;">{$vo.remark}</td>
                                            <td>{$vo.time}</td>

                                            <td>
                                                <div class="form-button-action">

                                                    <button type="button" title="编辑" class="btn btn-primary" data-toggle="modal" data-target="#addRowModal2" onClick="edit_item('{$vo.id}')">
                                                        <i class="fa fa-edit"></i>编辑
                                                    </button>
                                                </div>



                                            </td>
                                        </tr>
                                        {/volist}

                                        </tbody>
                                    </table>

                                    <!-- 分页 (调取通用方法)-->
                                     <div class="layui-box layui-laypage layui-laypage-molv">{:pagination($infos)}</div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
        </div>

        {include file="public/_footer" /}


    </div>



</div>

{include file="public/_js" /}

</body>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    var SCOPE = {
        'syn_status_url':"{:url('account/syn_status')}",
        'status_url':"{:url('account/status')}",
        'item_url':"{:url('operate/cityEdit')}",
        'add_url':"{:url('operate/citysave')}",
    };

    $(function(){
        var commitStatus = false;
        /*表单验证*/
        $("#form-modal3").validate({
            rules:{
                name:{
                    required:true,
                    minlength:2,
                    maxlength:11
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.add_url;
                if(commitStatus==true){
                    return false;
                }
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus==true
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                window.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

    });

    $(function(){
        var commitStatus = false;
        /*表单验证*/

        $("#form-modal2").validate({
            rules:{

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.add_url;
                if(commitStatus==true){
                    return false;
                }

                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

    });

    /*机构-停用*/
    function admin_stop2(obj,id){
        layer.confirm('确认要停用吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            var url = SCOPE.status_url;
            $.post(url,{status:2,id:id},function(data){
                if(data.code == 1001){
                    layer.msg('已停用!',{icon: 1,time:1000},function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:1000});
                }

            });


        });
    }


    function edit_item(id) {
        $("#form-modal2")[0].reset();
        $.ajax({
            type: 'GET',
            url: SCOPE.item_url,
            dataType: 'json',
            data: {id:id},
            success: function(res){
                if(res.code == 1001){
                    $("#id2").val(id);
                    $("#remark").val(res.data.remark);
                    $.each(res.data.pro_price,function (index,val){
                        $('#pro_price_'+index).val(val)
                    })
                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }

            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });
    }

    /*机构-启用*/
    function admin_start2(obj,id){
        layer.confirm('确认要启用吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……

            var url = SCOPE.status_url;
            $.post(url,{status:1,id:id},function(data){
                if(data.code == 1001){

                    layer.msg('已启用!',{icon: 1,time:1000},function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:1000});
                }
            });
        });
    }


    /*机构-停用*/
    function admin_stop(obj,id){
        layer.confirm('确认要暂停吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            var url = SCOPE.syn_status_url;
            $.post(url,{status:2,id:id},function(data){
                if(data.code == 1001){
                    layer.msg('已暂停!',{icon: 1,time:2000},function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:2000},function (){
                        window.location.reload();
                    });
                }

            });


        });
    }

    /*机构-启用*/
    function admin_start(obj,id){
        layer.confirm('确认要同步吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            var loading = layer.load('加载中...', {
                shade: [0.3,'#fff'] //0.1透明度的白色背景
            });
            var url = SCOPE.syn_status_url;

            $.post(url,{status:1,id:id},function(data){
                layer.close(loading);

                if(data.code == 1001){
                    layer.alert('已同步!', { icon: 1, closeBtn: 0 }, function (index) {
                        window.location.reload();
                    });
                }else{
                    layer.alert(data.msg, { icon: 1, closeBtn: 0 }, function (index) {
                        window.location.reload();
                    });
                }
            });
        });
    }

</script>
</html>




























